package hihocode;

import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;

public class XORSort {

	public static  long range = 1L << 60;
	
	public static void main(String[] args) {
//		Random random = new Random();
//		int testCase = random.nextInt(100);
//		long[] array;
//		System.out.println("testCase: " + testCase);
//		for(int i = 0; i < testCase; i++){
//			int length = random.nextInt(50);
//			System.out.println("length: " + length);
//			array = new long[length];
//			for (int j = 0; j < length; j++) {
//				array[j] = random.nextLong();
//				//System.out.println(array[j]);
//			}
//			long my = myCode(array, length);
//			long other = otherCode(array, length);
//			if(my != other){
//				System.out.println("length:" + length);
//				for (int j = 0; j < length; j++) {
//					System.out.print(array[j] + " ");
//				}
//				System.out.println();
//			}
//		}
		
		// 288230376151711744
		// 576460752303423488
		Scanner scanner = new Scanner(System.in);
		int n;
		long[] array;
		int[] lengths;
		label:
		while(scanner.hasNext()){
			int maxLength = 0;
			n = scanner.nextInt();
			array = new long[n];
			lengths = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = scanner.nextLong();
			}
			myCode(array, n);
//			if(n == 1){
//				System.out.println(range);
//				continue;
//			}
//			//判断每一位能够是否能取0 或 1
//			for(int i = 0; i < n; i++){
//				lengths[i] = getLength(array[i]);
//				maxLength = Math.max(maxLength, lengths[i]);
//			}
//			int diffCount = 0;
//			HashMap<Integer, Integer> map = new HashMap<>();
//			
//			for (int j = 1; j < n; j++) {
//				maxLength = Math.max(lengths[j], lengths[j - 1]);
//				for (int i = 31; i >= 0; i--) {
//					if (getBit(array[j], i) != getBit(array[j - 1], i)) {
//						//第i位应该为bit
//						int bit = getBit(array[j - 1], i);
//						Integer before;
//						
//						if ((before = map.get(i)) != null) {
//							//如果与之前的冲突，则无法满足条件
//							if (before != bit) {
//								System.out.println(0);
//								continue label;
//							}
//						} else {
//							// System.out.println("i : " + i + " bit : " + bit);
//							map.put(i, bit);
//							diffCount++;
//							break;
//						}
//					}
//				}
//			}
//			System.out.println(range / (1L << diffCount));
		}
		scanner.close();
		
	}
	
	//思路是对的，但是就是有边界条件不通过
	public static long myCode(long[] array, int n){
		if(n == 1){
			// System.out.println(range);
			return range;
		}
		//判断每一位能够是否能取0 或 1
		for(int i = 0; i < n; i++){
			// lengths[i] = getLength(array[i]);
			// maxLength = Math.max(maxLength, lengths[i]);
		}
		int diffCount = 0;
		HashMap<Integer, Integer> map = new HashMap<>();
		
		for (int j = 1; j < n; j++) {
			// maxLength = Math.max(lengths[j], lengths[j - 1]);
			for (int i = 63; i >= 0; i--) {
				if (getBit(array[j], i) != getBit(array[j - 1], i)) {
					//第i位应该为bit
					int bit = getBit(array[j - 1], i);
					Integer before;
					
					if ((before = map.get(i)) != null) {
						//如果与之前的冲突，则无法满足条件
						if (before != bit) {
							return 0;
						}
					} else {
						// System.out.println("i : " + i + " bit : " + bit);
						map.put(i, bit);
						diffCount++;
						break;
					}
				}
			}
		}
		// System.out.println(range / (1L << diffCount));
		return range / (1L << diffCount);
	}
	
	public static long otherCode(long[] arr, int n) {
		int[] result = new int[60];
		boolean flag = false;
		for (int j = 0; j < n - 1; ++j) {
			for (int i = 59; i >= 0; --i) {
				if (((arr[j] ^ arr[j + 1]) & 1L << i) != 0) {
					if ((arr[j] & 1L << i) != 0) {
						if (result[i] != -1) {
							result[i] = 1;
						} else {
							flag = true;
						}
					} else {
						if (result[i] != 1) {
							result[i] = -1;
						} else {
							flag = true;
						}
					}
					break;
				}
			}
			if (flag) {
				break;
			}
		}

		int res = 0;
		if (flag) {
			// System.out.println(0);
			return 0;
		} else {
			for (int i = 0; i < result.length; i++) {
				if (result[i] == 0) {
					res++;
				}
			}
			// System.out.println(1L << res);
			return 1L << res;
		}
	}
	
	public static int getLength(long num){
		if(num == 0){
			return 1;
		}
		int length = 0;
		while(num != 0){
			length++;
			num >>>= 1;
		}
		return length;
	}
	
	public static int getBit(long num, int j){
		return (int) ((num >>> j) & 1);
	}
}
